package com.nowcoder;

import java.util.Scanner;

/**
 *请解析IP地址和对应的掩码，进行分类识别。要求按照A/B/C/D/E类地址归类，不合法的地址和掩码单独归类。
 */
public class IPAddress {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        int a=0, b=0, c=0, d=0, e=0, err=0, pri=0;
        while (in.hasNext()) { // 注意 while 处理多个 case
            String line = in.nextLine();
            String[] ips = line.split("~");
            String ip = ips[0];
            String mask = ips[1];
            String[] ipnums = ip.split("\\.");
            String[] masknums = mask.split("\\.");
            boolean error = false;
            StringBuilder maskbinarys = new StringBuilder();
            if (masknums.length != 4 || ipnums.length != 4) {
                err++;
                continue;
            }
            int ipnum1 = Integer.parseInt(ipnums[0]);
            if (ipnum1 == 0 || ipnum1 == 127) {
                continue;
            }
            for (int i = 0; i < 4; i++) {
                int ipnum = Integer.parseInt(ipnums[i]);
                if(ipnum < 0 || ipnum > 255){
                    error = true;
                    break;
                }
                int masknum = Integer.parseInt(masknums[i]);
                if(masknum < 0 || masknum > 255){
                    error = true;
                    break;
                }
                String binary = Integer.toBinaryString(masknum);
                while(binary.length()<8){
                    binary = "0" + binary;
                }
                maskbinarys.append(binary);
            }
            if (error || maskbinarys.lastIndexOf("1") > maskbinarys.indexOf("0")) {
                err++;
                continue;
            }
            int ipnum2 = Integer.parseInt(ipnums[1]);
            if (ipnum1 >= 1 && ipnum1 <= 126) {
                a++;
            }
            if (ipnum1 >= 128 && ipnum1 <= 191) {
                b++;
            }
            if (ipnum1 >= 192 && ipnum1 <= 223) {
                c++;
            }
            if (ipnum1 >= 224 && ipnum1 <= 239) {
                d++;
            }
            if (ipnum1 >= 240 && ipnum1 <= 255) {
                e++;
            }
            if (ipnum1 == 10 || (ipnum1 == 172 && ipnum2 >= 16 && ipnum2 <=31) || (ipnum1 == 192 && ipnum2 == 168)) {
                pri++;
            }
        }
        System.out.println(a + " " + b + " " + c + " " + d + " " + e + " " + err + " " + pri);
    }
}
